package com.shigen.demo.datastruct.tree;

import com.shigen.demo.datastruct.tree.impl.AbstractTreeImpl;

/**
 * 主测试类
 *
 * @author shigenfu
 * @date 2022/7/12 4:55 下午
 */
public class Main {

  public static void main(String[] args) {
    Node a = new Node(1);
    Node b = new Node(2);
    Node c = new Node(3);
    Node d = new Node(4);
    Node e = new Node(5);

    // a.leftNode = c;
    // a.rightNode = b;
    // b.leftNode = d;
    // c.rightNode = e;

    AbstractTreeImpl abstractTree = new AbstractTreeImpl();
    // abstractTree.preOrder(a);
    // System.out.println();
    // abstractTree.inOrder(a);
    // System.out.println();
    // abstractTree.postOrder(a);
    // System.out.println();
    // int nodeCount = abstractTree.getNodeCount(a);
    // System.out.println(nodeCount);
    // System.out.println(abstractTree.getLeafNodeCount(a));
    // System.out.println(abstractTree.getHeight(a));
    // System.out.println(abstractTree.contains(a, 3));
    // System.out.println(abstractTree.getKLevelNode(a, 2));
    // System.out.println(abstractTree.getKLevelNode(a, 100));

    Node root = new Node(10);
    abstractTree.addRecursive(root, 5);
    abstractTree.addRecursive(root, 12);
    abstractTree.addRecursive(root, 3);
    abstractTree.addRecursive(root, 100);
    abstractTree.addRecursive(root, -10);
    abstractTree.addRecursive(root, -100);
    abstractTree.addRecursive(root, 5);
    abstractTree.addRecursive(root, 101);
    abstractTree.addRecursive(root, 10);

    abstractTree.preOrder(root);
    System.out.println();
    abstractTree.inOrder(root);
    System.out.println();
    abstractTree.postOrder(root);
    System.out.println(abstractTree.getHeight(root));

    System.out.println(abstractTree.getNode(root, 1001));
    System.out.println(abstractTree.getNode(root, 10));

    abstractTree.deleteNode(root, -100);
    abstractTree.preOrder(root);
    System.out.println(abstractTree.getNode(root, 10));
    abstractTree.traverseLevelOrder(root);
  }

}
